package com.nineclock.system.controller;

import com.nineclock.common.entity.Result;
import com.nineclock.system.service.SysSmsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping("/sms")
public class SysSmsController {
    @Autowired
    private SysSmsService sysSmsService;

    /**
     * 发送验证码
     *
     * @return
     */
    @GetMapping("/code")
    public Result sms(@RequestParam Map<String, String> map) {
        sysSmsService.sms(map);
        return Result.success();
    }

    /**
     * 验证码校验 必须返回boolean的结果,直接返回Result.success()不传参数前端会响应错误信息
     *
     * @return
     */
    @GetMapping("/verify")
    public Result verify(@RequestParam Map<String, String> map) {
        Boolean flag = sysSmsService.verify(map);
        return Result.success(flag);
    }
}
